package leetcode_601_700;

public class LeeCode_605 {
    public static void main(String[] args) {
        System.out.println(canPlaceFlowers(new int[]{1, 0, 0, 0, 1}, 1));
    }
    private static boolean canPlaceFlowers(int[] flowerbed, int n) {
        int count = 1, num = 0;
        for (int j : flowerbed) {
            if (j == 0) {
                count++;
            } else {
                count = 0;
            }
            if (count == 3) {
                count = 1;
                num++;
            }
        }
        if (count == 2){
            num++;
        }
        return n <= num;
    }
}
